#!/usr/bin/env python3
# -*- encoding: utf-8 -*-
'''
@author: yuejl
@application:
@contact: lewyuejian@163.com
@file: models.py
@time: 2021/8/12 0012 23:15
@desc:
'''
from enum import Enum
from typing import Text, Dict, Union, List, Any
from pydantic import BaseModel, Field

Name = Text
Url = Text
Init = Text
Headers = Dict[Text, Text]
Cookies = Dict[Text, Text]
RequestId = Text

class Config(BaseModel):
    name: Name = None
    url: Url = None
    init: Init = None
    path: Text = None

class MethodEnum(Text, Enum):
    GET = "GET"
    POST = "POST"
    PUT = "PUT"
    DELETE = "DELETE"

class AddressData(BaseModel):
    client_ip: Text = "N/A"
    client_port: Text = 0
    server_ip: Text = "N/A"
    server_port: int = 0

class RequestData(BaseModel):
    request_id: RequestId
    method: MethodEnum
    url: Url
    headers: Headers = {}
    cookies: Cookies = {}
    data: Union[Text, Dict[Text, Any]] = None
    params: Dict[Text, Text] = {}
    req_json: Union[Dict, List, Text] = Field(None, alias="json")

    timeout: float = 120

class HttpResponseResult(BaseModel):
    #status_code: int
    headers: Dict
    #cookies: Cookies
    encoding: Union[Text, None] = None
    content_type: Text
    body: Union[Text, bytes, Dict, List] = None


